<template>
<h2>修改积分</h2>
<table class="tale table-bordered">
    <tr>
        <td>最初积分</td>
        <td>
            <span>{{ minfo.jifen }}</span>
        </td>
    </tr>
    <tr>
        <td>更改积分</td>
        <td>
            <input type="text" v-model="info.jifen"/>
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <input type="radio" :value="0" v-model="info.code"/>增加
            <input type="radio" :value="1" v-model="info.code"/>减少
        </td>
    </tr>
    <tr>
        <td>备注</td>
        <td>
            <input type="text" />
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <input type="button" value="提交" class="btn btn-info" @click="Updjifen" />
        </td>
    </tr>
</table>
</template>
<script setup lang="ts">
import {ref,onMounted} from 'vue'
import axios from 'axios'
import { useRouter,useRoute } from 'vue-router';
const router=useRouter()
const route=useRoute()

const info=ref({
    jifen:'',
    code:0
})

const minfo=ref({
    mid:0,
    mname:'',
    phone:'',
    sex:'男',
    birenday:'',
    ymoney:0,
    jifen:0,
    image:''
})
onMounted(()=>{
    axios.get('https://localhost:7279/api/Meber/GetMeber',{
        params:{
            id:route.params.id
        }
    })
    .then(res=>{
        minfo.value=res.data
    })
    .catch(err=>{
        console.log(err)
    })
})
//修改积分
const Updjifen=()=>{
    axios.get('https://localhost:7279/api/Meber/UpdJifen',{
        params:{
            id:route.params.id,
            jifen:info.value.jifen,
            code:info.value.code
        }
    })
    .then(res=>{
        if(res.data>0){
            alert('修改成功')
            router.push('/MeberShow')
        }
        else{
            alert('修改失败')
        }
    })
    .catch(err=>{
        console.log(err)
    })
}


</script>